package com.sw.study.ssm.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Created by sw on 2020/4/18.
 */
@Controller
@RequestMapping("/user")
public class LoginController  {

    @RequestMapping("/login")
    public String to_login(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("跳转到登录页面");
        return "login";
    }

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public String login(HttpServletRequest request,
                        String username, String password,
                        RedirectAttributes redirectAttributes) {

        HttpSession session = request.getSession();
        session.setAttribute("username", username);
        session.setAttribute("password", password);

        return "redirect:/resume/list";
    }


}